//
//  ViewController.m
//  MirkoLibTest
//
//  Created by Mirko on 16/6/30.
//  Copyright © 2016年 Mirko. All rights reserved.
//

#import "ViewController.h"
#import <MCPublicModule/MCPMCommonHeader.h>
//#import <MCPublicModule/MCBasicAppEngine.h>
#import <MCPublicModule/HDEasterEggsCenter.h>
#import <MCPublicModule/AFHTTPRequestOperation.h>
#import <CommonCrypto/CommonDigest.h>
#import <MCPublicModule/MCPublicModule.h>
//#import <MCPublicModule/MCBasicNetworkEngine.h>
#import "TestNetworkEngine.h"

#import "HDSelectMonthViewController.h"

/**
 *  设备ID
 */
#define DEVICE_ID_DATA @"HD_deviceID"

/**
 *  设备key
 */
#define DEVICE_KEY_DATA @"HD_deviceKey"

@interface ViewController ()/*<MBProgressHUDDelegate>*/

@property(nonatomic,strong) NSString *deviceID;
@property(nonatomic,strong) NSString *deviceKey;
@property(nonatomic,assign) NSInteger userID;
@property(nonatomic,strong) NSString *userKey;
@property(nonatomic,strong) NSString *userSign;
@property(nonatomic,strong) NSString *userCode;


@end

@implementation ViewController

-(void) handelAction:(UINavigationController *)navController
{
    [navController pushViewController:self animated:YES];
}

- (IBAction)TestWebView:(UIButton *)sender {
    
    
}

- (IBAction)buttonAction:(id)sender {
    HDSelectMonthViewController *vc = (HDSelectMonthViewController *) [HDSelectMonthViewController loadIBVCIdentifier:nil];
    
    vc.noteString = @"可补缴最近一个月，可缴纳2016年12月及之后月份，截止时间为12月20日。可补缴最近一个月，可缴纳2016年12月及之后月份，截止时间为12月20日。";
    
    vc.timeRange = [NSArray arrayWithObjects:@"2016-10", @"2018-4", nil];
    vc.timeRange = [NSArray arrayWithObjects:@"2017-5", @"2017-10", nil];
    
    vc.timeRange = [NSArray arrayWithObjects:@"2016-3", @"2017-10", nil];
//
//    vc.timeRange = [NSArray arrayWithObjects:@"2017-7", @"2018-5", nil];
//    
    
    [self.navigationController pushViewController:vc animated:YES];
}

//-(NSString *)addPOSTParameter:(NSDictionary *)parmeter{
//    NSMutableDictionary *AllParmeter = [NSMutableDictionary dictionaryWithDictionary:parmeter];
//    NSString *dateString = [self getDateFomatter];
//    self.userSign = [self getUserSignWithDateString:dateString];
//    
//    [AllParmeter setValue:@"2" forKey:@"os_type"];
//    [AllParmeter setValue:self.deviceID forKey:@"auth_did"];
//    [AllParmeter setValue:dateString forKey:@"auth_tms"];
//    [AllParmeter setValue:[self getDeviceSignWithDateString:dateString] forKey:@"auth_dsig"];
//    [AllParmeter setValue:[NSString stringWithFormat:@"%ld",self.userID] forKey:@"auth_uid"];
//    [AllParmeter setValue:XDQ_APPID forKey:@"appid"];
//    [AllParmeter setValue:self.userSign forKey:@"auth_usig"];
//    
//    //   key:app_version 上传版本规则 例如：2.6.5 - 265 -26500
//    NSDictionary *appInfos = [[NSBundle mainBundle] infoDictionary];
//    NSMutableString *versionStr = [NSMutableString stringWithString:appInfos[@"CFBundleShortVersionString"]];
//    NSString *vStr = [versionStr stringByReplacingOccurrencesOfString:@"." withString:@""];
//    NSString *appVersion = [NSString stringWithFormat:@"%@", vStr];
//    [AllParmeter setValue:appVersion forKey:@"app_version"];
//    
//    NSMutableString *ALLPartmeterString = [[NSMutableString alloc] initWithString:@"?"];
//    for(NSString *key in AllParmeter.allKeys){
//        [ALLPartmeterString appendFormat:@"%@=%@&",key,[AllParmeter objectForKey:key]];
//    }
//    [ALLPartmeterString deleteCharactersInRange:NSMakeRange(ALLPartmeterString.length-1, 1)];
//    
//    NSLog(@"POST验证： %@", AllParmeter);
//    NSLog(@"－－－－－－－－－－验证DID： %@", self.deviceID);
//    return ALLPartmeterString;
//}
//
////获取tms
//-(NSString *)getDateFomatter {
//    NSDate *nowDate = [NSDate date];
//    NSDateFormatter *fomatter = [[NSDateFormatter alloc] init];
//    [fomatter setDateFormat:@"yyyyMMddHHmmss"];
//    NSString *dateString = [fomatter stringFromDate:nowDate];
//    
//    NSLog(@"验证时间: %@", dateString);
//    return dateString;
//}
//
////根据tms获取usig
//-(NSString *)getUserSignWithDateString:(NSString *)dateString{
//    NSString *signBefore = [NSString stringWithFormat:@"%@%@",@"10002",dateString];
//    NSString *signAfterMD5 = [self MD5WithString:signBefore];
//    NSString *signAfterClip = [signAfterMD5 substringWithRange:NSMakeRange(8, 16)];
//    return signAfterClip;
//}
//
//-(NSString *)MD5WithString:(NSString *)string{
//    const char *cStr = [string UTF8String];
//    unsigned char result[16];
//    CC_MD5( cStr, (CC_LONG)strlen(cStr), result );
//    return [NSString stringWithFormat:
//            @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
//            result[0], result[1], result[2], result[3],
//            result[4], result[5], result[6], result[7],
//            result[8], result[9], result[10], result[11],
//            result[12], result[13], result[14], result[15]
//            ];
//    
//}

//- (IBAction)showWithCustomView:(id)sender {
//    
//    HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
//    [self.navigationController.view addSubview:HUD];
//    
//    // The sample image is based on the work by http://www.pixelpressicons.com, http://creativecommons.org/licenses/by/2.5/ca/
//    // Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators)
//    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
//    view.backgroundColor = [UIColor redColor];
//    
//    
//    HUD.customView = view;
////    HUD.margin = 0;
//    
//    // Set custom view mode
//    HUD.mode = MBProgressHUDModeCustomView;
//    
//    [HUD show:YES];
//    [HUD hide:YES afterDelay:3];
//}
//
//- (IBAction)showSimple:(id)sender {
//    // The hud will dispable all input on the view (use the higest view possible in the view hierarchy)
//    HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
//    [self.navigationController.view addSubview:HUD];
//    
//    // Regiser for HUD callbacks so we can remove it from the window at the right time
//    HUD.delegate = self;
//    
//    // Show the HUD while the provided method executes in a new thread
//    [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
//}
//
//- (IBAction)showWithLabel:(id)sender {
//    
//    HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
//    [self.navigationController.view addSubview:HUD];
//    
//    HUD.delegate = self;
//    HUD.labelText = @"Loading";
//    HUD.mode = MBProgressHUDModeText;
//    HUD.blur = NO;
//    
//    [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
//}
//
//
//
//- (IBAction)showWithDetailsLabel:(id)sender {
//    
//    HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
//    [self.navigationController.view addSubview:HUD];
//    
//    HUD.delegate = self;
//    HUD.labelText = @"Loading";
//    HUD.detailsLabelText = @"updating data";
//    HUD.square = YES;
//    
//    [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
//}
//
//- (IBAction)showWithLabelDeterminate:(id)sender {
//    
//    HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
//    [self.navigationController.view addSubview:HUD];
//    
//    // Set determinate mode
//    HUD.mode = MBProgressHUDModeDeterminate;
//    
//    HUD.delegate = self;
//    HUD.labelText = @"Loading";
//    
//    // myProgressTask uses the HUD instance to update progress
//    [HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES];
//}
//
//- (void)myProgressTask {
//    // This just increases the progress indicator in a loop
//    float progress = 0.0f;
//    while (progress < 1.0f) {
//        progress += 0.01f;
//        HUD.progress = progress;
//        usleep(50000);
//    }
//}
//
//- (void)myTask {
//    // Do something usefull in here instead of sleeping ...
//    sleep(3);
//}



//- (void)viewDidLoad {
//    [super viewDidLoad];
//
//    [[MCBasicAppEngine instance] installVersionCompatibility];
//    
//    MCBasicViewController *vc1 = [[MCBasicViewController alloc] init];
//    vc1.view.backgroundColor = [UIColor redColor];
//    
//    MCBasicViewController *vc2 = [[MCBasicViewController alloc] init];
//    vc2.view.backgroundColor = [UIColor greenColor];
//    
//    [[HDEasterEggsCenter easterEggsCenter] registerJumpViewController:vc1,vc2,nil];
//    
//    DLOG(@"");
//    
//    
//    
//}

-(void) viewDidLoad
{
    [super viewDidLoad];
    
    NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES) firstObject];
    DLOG(@"%@", docPath);
    
//    TestNetworkEngine *test = [TestNetworkEngine instance];
//    test.onlineUrl =  @"http://interface.api.haodai.com/bapi/Advert/getGuideAds";
//    test.offlineUrl = @"http://interface.test.haodai.com/bapi/Advert/getGuideAds";
    
    //    return @"http://interface.test.haodai.com/bapi/Advert/getGuideAds";
    //
    //}
    //
    //-(NSString *) onlineUrlString
    //{
    //    return @"http://interface.api.haodai.com/bapi/Advert/getGuideAds";
    
    
    NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];
    DLOG(@"%@", url);
    
    
    
//    if available(iOS 10.0, *) {
//        // Use UserNotification
//    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
